// - 服务器推动消息给浏览器
var app = require('express')();
var server = require('http').Server(app);
//建立的通道一直在 w:// http://
var WebSocket = require('ws')
var wss = new WebSocket.Server({port:8075})
wss.on('connection',function (ws) {
    console.log('server:receive connection');
    // 客户端发送消息
    ws.on('message',function (msg) {
        console.log('server:received:%s',msg);
    })
    ws.send('server world');
    setTimeout(()=>{
        ws.send('hello world')
    },5000)

})
// url / get
app.get('/',function (req,res) {
    res.sendFile(__dirname +'/index.html')
})
app.listen(3002);